<template>
    <div id="header">
        <div id="header-middle">
            <el-icon>
                <Box />
            </el-icon>
            <p></p>
            YsTools
        </div>
        <div id="header-right">
            <el-icon  size="28" id="topBtn" @click="control_windwo_top">
                <Top />
            </el-icon>
            <el-icon  size="28" id="minBtn" @click="control_window_min">
                <Minus />
            </el-icon>
            <el-icon  size="28" id="closeBtn" @click="control_window_close">
                <Close />
            </el-icon>
        </div>
    </div>
</template>

<script setup>
import { appWindow,LogicalPosition,PhysicalPosition } from '@tauri-apps/api/window'
import { ref ,onMounted} from 'vue'
import {Close,Minus,Top,Box} from '@element-plus/icons-vue';

const  top_state = ref('false');
const  top_state_color = ref('black')
const control_windwo_top = async ()=>
{
    top_state.value = !top_state.value ;
    if(top_state.value){
        top_state_color.value = 'white'
    }else{
        top_state_color.value = 'black'
    }
    appWindow.setAlwaysOnTop(top_state.value)
};
const control_window_min = async ()=>
{
    appWindow.minimize();
};
const control_window_close = async ()=>
{
    appWindow.close();
};
onMounted(()=>{
    const header_dom = document.getElementById('header-middle');
    header_dom.onmousedown = async (event) =>{
        await appWindow.startDragging();
    };
});

</script>
<style>
*{
    user-select: none;
}
#header{
    position: relative;
    display: flex;
    width: 100%;
    height: 35px;
    background-image: linear-gradient(to right, #00dbde 0%, #fc00ff 100%);
}
#header-middle{
    width: 80%;
    height: 100%;
    margin: 0 auto;
    font-size: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#header-right{
    display: flex;
    position: absolute;
    align-items: center;
    justify-content: center;
    height: 100%;
    right: 0px;
}
#topBtn{
    border: 1.5px solid v-bind(top_state_color);
    color: black;
}
#topBtn:hover{
    color: white;
}
#minBtn{
    color: black;
}
#minBtn:hover{
    color: white;
}
#closeBtn{
    color: black;
}
#closeBtn:hover{
    color: white;
}
</style>